﻿using HelixToolkit.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Media3D;

namespace Learn3D.Helix
{
    public class MainViewModel
    {
        public Model3D Model { get; set; }

        public MainViewModel()
        {
            // Create a model group
            Model3DGroup modelGroup = new Model3DGroup();

            // Create a mesh builder and add a box to it
            MeshBuilder meshBuilder = new MeshBuilder(false, false);
            meshBuilder.AddBox(new Point3D(0, 0, 0), 20, 10, 5);


            // Create a mesh from the builder (and freeze it)
            MeshGeometry3D mesh = meshBuilder.ToMesh(true);

            // Create some materials       
            var blueMaterial = MaterialHelper.CreateMaterial(Colors.Red);
            var insideMaterial = MaterialHelper.CreateMaterial(Colors.Yellow);

            // Add model to the group (using the same mesh, that's why we had to freeze it)    
            modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Transform = new TranslateTransform3D(60, 0, 60), Material = blueMaterial, BackMaterial = insideMaterial });

            // Set the property, which will be bound to the Content property of the ModelVisual3D (see MainWindow.xaml)
            this.Model = modelGroup;
        }

    }
}
